package com.sudoku.listener;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import com.sudoku.common.Constants;
import com.sudoku.common.SqliteUtils;
import com.sudoku.ui.Sudoku;

public class MenuExitListener implements ActionListener {

	private Sudoku sudoku;
	public MenuExitListener(Sudoku sudoku) {
		this.sudoku = sudoku;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		
		if (Constants.LABEL_PUZZLE.equals(sudoku.getAtCard())) {
			SqliteUtils.insert(sudoku);
		}
		
		/**
		 * 关闭数据库链接
		 */
		SqliteUtils.closeConnection();
		
		System.exit(0);
	}

}
